#include <iostream>
using namespace std;

int main() {
    int n,val;
    cin >> n;
    cin >> val;
    int min = val;
    int max = val;
    
    int max_diff;
    for (int i = 1; i < n; i++)
    {
        cin >> val;
        if (val > max)
        {
            max = val;
        }
        if (val < min)
        {
            min = val;
        }
    }
    max_diff = max - min;
    cout << max_diff;
    
    return 0;
}